package com.ethink.order.facadeImpl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ethink.order.api.PurchaseReturnOrderFacade;
import com.ethink.order.api.info.PurchaseReturnOrderModeInfo;
import com.ethink.order.api.model.PurchaseReturnModel;
import com.ethink.order.api.request.PurchaseReturnOrderAddRequest;
import com.ethink.order.api.request.PurchaseReturnOrderUpdateRequest;
import com.ethink.order.api.request.PurchaseReturnPageModeQueryRequest;
import com.ethink.order.api.request.PurchaseReturnPageQueryRequest;
import com.ethink.order.api.response.PurchaseReturnDetailResponse;
import com.ethink.order.manager.PurchaseReturnManager;
import com.ethink.order.service.PurchaseReturnOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 采购退单 Facade接口实现
 *
 * @author default
 * @date 2022-12-06
 */
@RestController
@Slf4j
@RequestMapping("order-service/facade/v1/purchaseReturnOrder")
public class PurchaseReturnOrderFacadeImpl implements PurchaseReturnOrderFacade {

    @Autowired
    private PurchaseReturnOrderService purchaseReturnOrderService;

    @Autowired
    private PurchaseReturnManager purchaseReturnManager;

    @Override
    public Long add(PurchaseReturnOrderAddRequest addRequest) {
        return purchaseReturnOrderService.add(addRequest);
    }

    @Override
    public Page<PurchaseReturnModel> pageQuery(PurchaseReturnPageQueryRequest request) {
        return purchaseReturnOrderService.pageQuery(request);
    }

    @Override
    public PurchaseReturnDetailResponse queryDetail(Long id) {
        return purchaseReturnOrderService.queryDetail(id);
    }

    @Override
    public Boolean delete(Long id) {
       return purchaseReturnOrderService.delete(id);
    }

    @Override
    public Boolean update(PurchaseReturnOrderUpdateRequest updateRequest) {
        return purchaseReturnOrderService.update(updateRequest);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean pass(Long id) {
        return purchaseReturnManager.pass(id);
    }

    @Override
    public Boolean refuse(Long id) {
        return purchaseReturnManager.refuse(id);
    }

    @Override
    public List<String> queryPurchaseReturnDetailOrderNosByOrderNos(List<String> orderNos) {
        return purchaseReturnOrderService.queryPurchaseReturnDetailOrderNosByOrderNos(orderNos);
    }

    @Override
    public Page<PurchaseReturnOrderModeInfo> pageModeQuery(PurchaseReturnPageModeQueryRequest request) {
        return purchaseReturnOrderService.pageModeQuery(request);
    }
}